package com.sy.blog.controller;


import com.sy.blog.service.TagService;
import com.sy.blog.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("tags")
public class TagController {

    @Autowired
    private TagService tagService;

    /**
     * 选出使用次数前6的标签
     * @return
     */
    @GetMapping("hot")
    public Result hotTags() {
        int limit = 6;
        return tagService.findHotTagsByTagId(limit);
    }

    /**
     * 发布文章时选择的所有标签
     * @return
     */
    @GetMapping
    public Result listTags() {
        return tagService.findAll();
    }

    /**
     * 详细标签
     * @return
     */
    @GetMapping("detail")
    public Result listTagsDetail() {
        return tagService.findAllDetail();
    }

    @GetMapping("detail/{id}")
    public Result listTagsDetail(@PathVariable("id") Long id) {
        return tagService.findDetailById(id);

    }


}
